package com.company.bookstore.aspect;

import org.redisson.api.RRateLimiter;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class LimitRateFactory {
    public static final Map<String, RRateLimiter> LIMIT_MAP = new ConcurrentHashMap<>();
    public static boolean invoke (String key){
        return LIMIT_MAP.get(key).tryAcquire();
    }
    public static void register (String key,RRateLimiter rRateLimiter){
         LIMIT_MAP.put(key,rRateLimiter);
    }
    public static boolean containKey(String key){
        return LIMIT_MAP.containsKey(key);
    }
}
